package at.fhj.itm10.ticketmaster.entities;

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;

/**
*
* @author Benjamin Hirt , Rene Schuster
*/

public class Event implements Entity{
	long id; 
	String name;
	String dateTime;
	int primeevent; 
	double ticketPrice;
	int ticketAmount;
	int eventCanceled;
	String description;
	String enter;
	String begin;
	String flyer;
	long fkAddressId;
	int fkCustomerId;
	int fkEventtypeId;
	int standingAmount;
	int seatAmount;
	int logeAmount;
	double standingPrice;
	double seatPrice;
	double logePrice;

	public Event(long id, String name, String dateTime, int primeevent, 
			double ticketPrice, int ticketAmount,int standingAmount, int seatAmount,
			int logeAmount, double standingPrice, double seatPrice,
			double logePrice, int eventCanceled, String description, 
			String enter, String begin, String flyer, int fkAddressId, int fkCustomerId,
			int fkEventtypeId) {
		setId(id);
		setName(name);
		setDateTime(dateTime);
		setPrimeevent(primeevent);
		setTicketAmount(ticketAmount);
		setTicketPrice(ticketPrice);
		setStandingAmount(standingAmount);
		setSeatAmount(seatAmount);
		setLogeAmount(logeAmount);
		setStandingPrice(standingPrice);
		setSeatPrice(seatPrice);
		setLogePrice(logePrice);
		setEventCanceled(eventCanceled);
		setDescription(description);
		setEnter(enter);
		setBegin(begin);
		setFlyer(flyer);
		setFkAddressId(fkAddressId);
		setFkCustomerId(fkCustomerId);
		setFkEventtypeId(fkEventtypeId);
	}

	public Event() {
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDateTime() {
		return dateTime;
	}
	
	/**
	 * 
	 * Converts the time string into the format: hh:mm 
	 * 
	 * @return String 
	 */
	
	public String getDateTimeHoursOnly() {
		
		String[] dateTimeHours = getEnter().split(" ");
		
		dateTimeHours[1] = dateTimeHours[1].substring(0, 5);
		System.out.println(dateTime);
		return dateTimeHours[1];
	}
	
	
	/**
	 * 
	 * Converts the time string into the format: dd:mm:yyyy
	 * 
	 * @return String 
	 */
	public String getDateTimeDateOnly() {
		
		String[] temp = dateTime.split(" ");
		String[] dateTimeDateArray = temp[0].split("-");
		String dateTimeDate = dateTimeDateArray[2] + "." + dateTimeDateArray[1] + "." + dateTimeDateArray[0];
		return dateTimeDate;
	}

	public void setDateTime(String dateTime) {
		this.dateTime = dateTime;
	}

	public int getPrimeevent() {
		return primeevent;
	}

	public void setPrimeevent(int primeevent) {
		this.primeevent = primeevent;
	}

	public double getTicketPrice() {
		return ticketPrice;
	}
	
	
	/**
	 * 
	 * Converts the price value(string) into a decimalvalue
	 * 
	 * 
	 * @return String 
	 */
	
	public String getTicketPriceDecimal() {
		DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols(Locale.GERMAN);
		otherSymbols.setDecimalSeparator('.');
		
		DecimalFormat df = new DecimalFormat("0.00", otherSymbols);
		return df.format(ticketPrice);
	}
	
	
	/**
	 * 
	 * Converts the price value(string) of a standing ticket into a decimalvalue
	 * 
	 * 
	 * @return String 
	 */

	public String getStandingTicketPriceDecimal() {
		DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols(Locale.GERMAN);
		otherSymbols.setDecimalSeparator('.');
		
		DecimalFormat df = new DecimalFormat("0.00", otherSymbols);
		return df.format(standingPrice);
	}
	
	/**
	 * 
	 * Converts the price value(string) of a seating ticket into a decimalvalue
	 * 
	 * 
	 * @return String 
	 */
	
	public String getSeatingTicketPriceDecimal() {
		DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols(Locale.GERMAN);
		otherSymbols.setDecimalSeparator('.');
		
		DecimalFormat df = new DecimalFormat("0.00", otherSymbols);
		return df.format(seatPrice);
	}
	
	/**
	 * 
	 * Converts the price value(string) of a loge ticket into a decimalvalue
	 * 
	 * 
	 * @return String 
	 */
	
	public String getLogeTicketPriceDecimal() {
		DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols(Locale.GERMAN);
		otherSymbols.setDecimalSeparator('.');
		
		DecimalFormat df = new DecimalFormat("0.00", otherSymbols);
		return df.format(logePrice);
	}
	
	public void setTicketPrice(double ticketPrice) {
		this.ticketPrice = ticketPrice;
	}

	
	public int getStandingAmount() {
		return standingAmount;
	}

	public void setStandingAmount(int standingAmount) {
		this.standingAmount = standingAmount;
	}

	public int getSeatAmount() {
		return seatAmount;
	}

	public void setSeatAmount(int seatAmount) {
		this.seatAmount = seatAmount;
	}

	public int getLogeAmount() {
		return logeAmount;
	}

	public void setLogeAmount(int logeAmount) {
		this.logeAmount = logeAmount;
	}

	public double getStandingPrice() {
		return standingPrice;
	}

	public void setStandingPrice(double standingPrice) {
		this.standingPrice = standingPrice;
	}

	public double getSeatPrice() {
		return seatPrice;
	}

	public void setSeatPrice(double seatPrice) {
		this.seatPrice = seatPrice;
	}

	public double getLogePrice() {
		return logePrice;
	}

	public void setLogePrice(double logePrice) {
		this.logePrice = logePrice;
	}

	public int getTicketAmount() {
		return ticketAmount;
	}

	public void setTicketAmount(int ticketAmount) {
		this.ticketAmount = ticketAmount;
	}
	
	
	public int getEventCanceled() {
		return eventCanceled;
	}

	public void setEventCanceled(int eventCanceled) {
		this.eventCanceled = eventCanceled;
	}
	
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getEnter() {
		return enter;
	}

	public void setEnter(String enter) {
		this.enter = enter;
	}

	public String getBegin() {
		return begin;
	}

	public void setBegin(String begin) {
		this.begin = begin;
	}

	public String getFlyer() {
		return flyer;
	}

	public void setFlyer(String flyer) {
		this.flyer = flyer;
	}

	public long getFkAddressId() {
		return fkAddressId;
	}

	public void setFkAddressId(long fkAdressId) {
		this.fkAddressId = fkAdressId;
	}

	public int getFkCustomerId() {
		return fkCustomerId;
	}

	public void setFkCustomerId(int fkCustomerId) {
		this.fkCustomerId = fkCustomerId;
	}

	public int getFkEventtypeId() {
		return fkEventtypeId;
	}

	public void setFkEventtypeId(int fkEventtypeId) {
		this.fkEventtypeId = fkEventtypeId;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (id ^ (id >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Event other = (Event) obj;
		if (id != other.id)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "id = [" + getId() + "], Name = [" + getName() + "], Date&Time = [" + getDateTime() +"], " +
				"is PrimeEvent = [" + getPrimeevent() + "], " + "TicketPrice = [" + getTicketPrice() + "], " +
				"standingAmount = [" + getStandingAmount() + "], " + "is EventCanceled = [" + getEventCanceled() +"], " +
				"seatAmount = [" + getSeatAmount() + "], " + "is EventCanceled = [" + getEventCanceled() +"], " +
				"logeAmount = [" + getLogeAmount() + "], " + "is EventCanceled = [" + getEventCanceled() +"], " +
				"Description = [" + getDescription() + "], " + "Enter = [" + getEnter() + "], " +
				"Begin = [" + getBegin() + "], " + "Flyer = [" + getFlyer() + "], " +
				"fkAddressId = [" + getFkAddressId() + "], " + "fkCustomerId = [" + getFkCustomerId() + "], " +
				"fkEventtypeId = [" + getFkEventtypeId() + "]";
	}


}
